import { Injectable } from '@angular/core';
import { BehaviorSubject, Observable } from 'rxjs';

@Injectable({
  providedIn: 'root'
})
export class AppStateService {
  private _keyStrategy = new BehaviorSubject<'id' | 'index' | 'none'>('id');
  keyStrategy$: Observable<'id' | 'index' | 'none'> = this._keyStrategy.asObservable();

  constructor() { }

  updateKeyStrategy(strategy: 'id' | 'index' | 'none'): void {
    this._keyStrategy.next(strategy);
    console.log('Key Strategy updated to:', strategy);
  }

  // If you need a direct getter for the current value
  getKeyStrategy(): 'id' | 'index' | 'none' {
    return this._keyStrategy.getValue();
  }
}